package com.ruoyi.web.controller.applet;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.BdmUserPraise;
import com.ruoyi.system.domain.dto.UserPraiseDto;
import com.ruoyi.system.service.IBdmUserPraiseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 小程序点赞Controller
 * 
 * @author ruoyi
 * @date 2024-12-12
 */
@RestController
@RequestMapping("/applet/praise")
public class AppletPraiseController extends BaseController
{
    @Autowired
    private IBdmUserPraiseService bdmUserPraiseService;

    /**
     * 查询点赞列表
     */
    @GetMapping("/list")
    public TableDataInfo list(BdmUserPraise bdmUserPraise)
    {
        startPage();
        List<BdmUserPraise> list = bdmUserPraiseService.selectBdmUserPraiseList(bdmUserPraise);
        return getDataTable(list);
    }

    /**
     * 获取点赞详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bdmUserPraiseService.selectBdmUserPraiseById(id));
    }

    /**
     * 新增点赞
     */
    @Log(title = "小程序点赞", businessType = BusinessType.INSERT)
    @PostMapping("/savePraise")
    public AjaxResult savePraise(@RequestBody UserPraiseDto userPraiseDto)
    {
        return toAjax(bdmUserPraiseService.savePraise(userPraiseDto));
    }
}
